<template>
  <div class="preview-box" ref="pre">
    <vue-office-pdf :src="fileUrl" v-if="fileShow"/>
  </div>
</template>

<script setup>
import {preview} from "@/api/OA/Seal"
const docxx = require("docx-preview")
import {onMounted, ref} from "vue"
import {useRoute} from "vue-router"
import {previewrule} from "@/api/index.js"
import VueOfficePdf from '@vue-office/pdf'
import {previewBorrow} from "@/api/Borrow/Borrow"

const fileShow = ref(false)
const fileUrl = ref('')


const id = ref()
const route = useRoute()
const pre = ref()

onMounted(()=>{
  id.value = route.query.approveId
  console.log(route)
  console.log(route.query)
  getFile()
})

const getFile = async () => {
  try {
    const res = await previewBorrow(id.value)
    // console.log(res)
    const blob = new Blob([res.data], { type: 'application/pdf' });
    fileUrl.value = window.URL.createObjectURL(blob)
    fileShow.value = true
  } catch (e) {
    console.log(e)
  }
}

</script>

<style scoped lang="less">
.preview-box{
  height: 100vh;
  width: 100vw;
  overflow-y: scroll;
  position: absolute;
  box-sizing: border-box;
}
</style>
